3.33 \(\int \frac{\tan (c+d x) (B \tan (c+d x)+C \tan ^2(c+d x))}{(a+b \tan (c+d x))^2} \, dx\)

Optimal. Leaf size=157 \[ -\frac{a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac{a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \log (a+b \tan (c+d x))}{b^2 d \left (a^2+b^2\right )^2}-\frac{\left (a^2 (-C)+2 a b B+b^2 C\right ) \log (\cos (c+d x))}{d \left (a^2+b^2\right )^2}-\frac{x \left (a^2 B+2 a b C-b^2 B\right )}{\left (a^2+b^2\right )^2} \]

[Out]

-(((a^2*B - b^2*B + 2*a*b*C)*x)/(a^2 + b^2)^2) - ((2*a*b*B - a^2*C + b^2*C)*Log[Cos[c + d*x]])/((a^2 + b^2)^2*
d) - (a*(2*b^3*B - a^3*C - 3*a*b^2*C)*Log[a + b*Tan[c + d*x]])/(b^2*(a^2 + b^2)^2*d) - (a^2*(b*B - a*C))/(b^2*
(a^2 + b^2)*d*(a + b*Tan[c + d*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.311219, antiderivative size = 157, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 38, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.158, Rules used = {3632, 3604, 3626, 3617, 31, 3475} \[ -\frac{a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac{a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \log (a+b \tan (c+d x))}{b^2 d \left (a^2+b^2\right )^2}-\frac{\left (a^2 (-C)+2 a b B+b^2 C\right ) \log (\cos (c+d x))}{d \left (a^2+b^2\right )^2}-\frac{x \left (a^2 B+2 a b C-b^2 B\right )}{\left (a^2+b^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Int[(Tan[c + d*x]*(B*Tan[c + d*x] + C*Tan[c + d*x]^2))/(a + b*Tan[c + d*x])^2,x]

[Out]

-(((a^2*B - b^2*B + 2*a*b*C)*x)/(a^2 + b^2)^2) - ((2*a*b*B - a^2*C + b^2*C)*Log[Cos[c + d*x]])/((a^2 + b^2)^2*
d) - (a*(2*b^3*B - a^3*C - 3*a*b^2*C)*Log[a + b*Tan[c + d*x]])/(b^2*(a^2 + b^2)^2*d) - (a^2*(b*B - a*C))/(b^2*
(a^2 + b^2)*d*(a + b*Tan[c + d*x]))

Rule 3632

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_.)*((A_.) + (B_.)
*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[1/b^2, Int[(a + b*Tan[e + f*x])
^(m + 1)*(c + d*Tan[e + f*x])^n*(b*B - a*C + b*C*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, A, B, C, m,
 n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - a*b*B + a^2*C, 0]

Rule 3604

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^2*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.)
 + (f_.)*(x_)])^(n_), x_Symbol] :> -Simp[((B*c - A*d)*(b*c - a*d)^2*(c + d*Tan[e + f*x])^(n + 1))/(f*d^2*(n +
1)*(c^2 + d^2)), x] + Dist[1/(d*(c^2 + d^2)), Int[(c + d*Tan[e + f*x])^(n + 1)*Simp[B*(b*c - a*d)^2 + A*d*(a^2
*c - b^2*c + 2*a*b*d) + d*(B*(a^2*c - b^2*c + 2*a*b*d) + A*(2*a*b*c - a^2*d + b^2*d))*Tan[e + f*x] + b^2*B*(c^
2 + d^2)*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^
2, 0] && NeQ[c^2 + d^2, 0] && LtQ[n, -1]

Rule 3626

Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/((a_.) + (b_.)*tan[(e_.) + (f_.)*
(x_)]), x_Symbol] :> Simp[((a*A + b*B - a*C)*x)/(a^2 + b^2), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2), I
nt[(1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Dist[(A*b - a*B - b*C)/(a^2 + b^2), Int[Tan[e + f*x], x
], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a
*B - b*C, 0]

Rule 3617

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[
A/(b*f), Subst[Int[(a + x)^m, x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int \frac{\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx &=\int \frac{\tan ^2(c+d x) (B+C \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx\\ &=-\frac{a^2 (b B-a C)}{b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{\int \frac{-a (b B-a C)+b (b B-a C) \tan (c+d x)+\left (a^2+b^2\right ) C \tan ^2(c+d x)}{a+b \tan (c+d x)} \, dx}{b \left (a^2+b^2\right )}\\ &=-\frac{\left (a^2 B-b^2 B+2 a b C\right ) x}{\left (a^2+b^2\right )^2}-\frac{a^2 (b B-a C)}{b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{\left (2 a b B-a^2 C+b^2 C\right ) \int \tan (c+d x) \, dx}{\left (a^2+b^2\right )^2}-\frac{\left (a \left (2 b^3 B-a^3 C-3 a b^2 C\right )\right ) \int \frac{1+\tan ^2(c+d x)}{a+b \tan (c+d x)} \, dx}{b \left (a^2+b^2\right )^2}\\ &=-\frac{\left (a^2 B-b^2 B+2 a b C\right ) x}{\left (a^2+b^2\right )^2}-\frac{\left (2 a b B-a^2 C+b^2 C\right ) \log (\cos (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac{a^2 (b B-a C)}{b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac{\left (a \left (2 b^3 B-a^3 C-3 a b^2 C\right )\right ) \operatorname{Subst}\left (\int \frac{1}{a+x} \, dx,x,b \tan (c+d x)\right )}{b^2 \left (a^2+b^2\right )^2 d}\\ &=-\frac{\left (a^2 B-b^2 B+2 a b C\right ) x}{\left (a^2+b^2\right )^2}-\frac{\left (2 a b B-a^2 C+b^2 C\right ) \log (\cos (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac{a \left (2 b^3 B-a^3 C-3 a b^2 C\right ) \log (a+b \tan (c+d x))}{b^2 \left (a^2+b^2\right )^2 d}-\frac{a^2 (b B-a C)}{b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end{align*}

Mathematica [C]  time = 2.05516, size = 324, normalized size = 2.06 \[ \frac{-2 i a \left (a^3 C+3 a b^2 C-2 b^3 B\right ) \tan ^{-1}(\tan (c+d x)) (a+b \tan (c+d x))+a \left (2 (a+i b)^2 (c+d x) \left (i a^2 C+2 a b C-b^2 B\right )+a \left (a^3 C+3 a b^2 C-2 b^3 B\right ) \log \left ((a \cos (c+d x)+b \sin (c+d x))^2\right )-2 C \left (a^2+b^2\right )^2 \log (\cos (c+d x))\right )+b \tan (c+d x) \left (2 (a+i b) \left (a^2 b (B+C (c+d x+i))+i a^3 C (c+d x+i)-a b^2 (B (c+d x+i)-2 i C (c+d x))-i b^3 B (c+d x)\right )+a \left (a^3 C+3 a b^2 C-2 b^3 B\right ) \log \left ((a \cos (c+d x)+b \sin (c+d x))^2\right )-2 C \left (a^2+b^2\right )^2 \log (\cos (c+d x))\right )}{2 b^2 d \left (a^2+b^2\right )^2 (a+b \tan (c+d x))} \]

Antiderivative was successfully verified.

[In]

Integrate[(Tan[c + d*x]*(B*Tan[c + d*x] + C*Tan[c + d*x]^2))/(a + b*Tan[c + d*x])^2,x]

[Out]

(a*(2*(a + I*b)^2*(-(b^2*B) + I*a^2*C + 2*a*b*C)*(c + d*x) - 2*(a^2 + b^2)^2*C*Log[Cos[c + d*x]] + a*(-2*b^3*B
 + a^3*C + 3*a*b^2*C)*Log[(a*Cos[c + d*x] + b*Sin[c + d*x])^2]) + b*(2*(a + I*b)*((-I)*b^3*B*(c + d*x) + I*a^3
*C*(I + c + d*x) - a*b^2*((-2*I)*C*(c + d*x) + B*(I + c + d*x)) + a^2*b*(B + C*(I + c + d*x))) - 2*(a^2 + b^2)
^2*C*Log[Cos[c + d*x]] + a*(-2*b^3*B + a^3*C + 3*a*b^2*C)*Log[(a*Cos[c + d*x] + b*Sin[c + d*x])^2])*Tan[c + d*
x] - (2*I)*a*(-2*b^3*B + a^3*C + 3*a*b^2*C)*ArcTan[Tan[c + d*x]]*(a + b*Tan[c + d*x]))/(2*b^2*(a^2 + b^2)^2*d*
(a + b*Tan[c + d*x]))

________________________________________________________________________________________

Maple [A]  time = 0.047, size = 313, normalized size = 2. \begin{align*}{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) Bab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) C{a}^{2}}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){b}^{2}C}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-2\,{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ) ab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{{a}^{2}B}{bd \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( dx+c \right ) \right ) }}+{\frac{C{a}^{3}}{{b}^{2}d \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( dx+c \right ) \right ) }}-2\,{\frac{ab\ln \left ( a+b\tan \left ( dx+c \right ) \right ) B}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{{a}^{4}\ln \left ( a+b\tan \left ( dx+c \right ) \right ) C}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}{b}^{2}}}+3\,{\frac{{a}^{2}\ln \left ( a+b\tan \left ( dx+c \right ) \right ) C}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x)

[Out]

1/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*B*a*b-1/2/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*C*a^2+1/2/d/(a^2+b^2)^2*ln(1+tan
(d*x+c)^2)*b^2*C-1/d/(a^2+b^2)^2*B*arctan(tan(d*x+c))*a^2+1/d/(a^2+b^2)^2*B*arctan(tan(d*x+c))*b^2-2/d/(a^2+b^
2)^2*C*arctan(tan(d*x+c))*a*b-1/d*a^2/b/(a^2+b^2)/(a+b*tan(d*x+c))*B+1/d*a^3/b^2/(a^2+b^2)/(a+b*tan(d*x+c))*C-
2/d*a/(a^2+b^2)^2*b*ln(a+b*tan(d*x+c))*B+1/d*a^4/(a^2+b^2)^2/b^2*ln(a+b*tan(d*x+c))*C+3/d*a^2/(a^2+b^2)^2*ln(a
+b*tan(d*x+c))*C

________________________________________________________________________________________

Maxima [A]  time = 1.67767, size = 266, normalized size = 1.69 \begin{align*} -\frac{\frac{2 \,{\left (B a^{2} + 2 \, C a b - B b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{2 \,{\left (C a^{4} + 3 \, C a^{2} b^{2} - 2 \, B a b^{3}\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} b^{2} + 2 \, a^{2} b^{4} + b^{6}} + \frac{{\left (C a^{2} - 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{2 \,{\left (C a^{3} - B a^{2} b\right )}}{a^{3} b^{2} + a b^{4} +{\left (a^{2} b^{3} + b^{5}\right )} \tan \left (d x + c\right )}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/2*(2*(B*a^2 + 2*C*a*b - B*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - 2*(C*a^4 + 3*C*a^2*b^2 - 2*B*a*b^3)*log(
b*tan(d*x + c) + a)/(a^4*b^2 + 2*a^2*b^4 + b^6) + (C*a^2 - 2*B*a*b - C*b^2)*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a
^2*b^2 + b^4) - 2*(C*a^3 - B*a^2*b)/(a^3*b^2 + a*b^4 + (a^2*b^3 + b^5)*tan(d*x + c)))/d

________________________________________________________________________________________

Fricas [B]  time = 1.30591, size = 682, normalized size = 4.34 \begin{align*} \frac{2 \, C a^{3} b^{2} - 2 \, B a^{2} b^{3} - 2 \,{\left (B a^{3} b^{2} + 2 \, C a^{2} b^{3} - B a b^{4}\right )} d x +{\left (C a^{5} + 3 \, C a^{3} b^{2} - 2 \, B a^{2} b^{3} +{\left (C a^{4} b + 3 \, C a^{2} b^{3} - 2 \, B a b^{4}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac{b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) -{\left (C a^{5} + 2 \, C a^{3} b^{2} + C a b^{4} +{\left (C a^{4} b + 2 \, C a^{2} b^{3} + C b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac{1}{\tan \left (d x + c\right )^{2} + 1}\right ) - 2 \,{\left (C a^{4} b - B a^{3} b^{2} +{\left (B a^{2} b^{3} + 2 \, C a b^{4} - B b^{5}\right )} d x\right )} \tan \left (d x + c\right )}{2 \,{\left ({\left (a^{4} b^{3} + 2 \, a^{2} b^{5} + b^{7}\right )} d \tan \left (d x + c\right ) +{\left (a^{5} b^{2} + 2 \, a^{3} b^{4} + a b^{6}\right )} d\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/2*(2*C*a^3*b^2 - 2*B*a^2*b^3 - 2*(B*a^3*b^2 + 2*C*a^2*b^3 - B*a*b^4)*d*x + (C*a^5 + 3*C*a^3*b^2 - 2*B*a^2*b^
3 + (C*a^4*b + 3*C*a^2*b^3 - 2*B*a*b^4)*tan(d*x + c))*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(tan
(d*x + c)^2 + 1)) - (C*a^5 + 2*C*a^3*b^2 + C*a*b^4 + (C*a^4*b + 2*C*a^2*b^3 + C*b^5)*tan(d*x + c))*log(1/(tan(
d*x + c)^2 + 1)) - 2*(C*a^4*b - B*a^3*b^2 + (B*a^2*b^3 + 2*C*a*b^4 - B*b^5)*d*x)*tan(d*x + c))/((a^4*b^3 + 2*a
^2*b^5 + b^7)*d*tan(d*x + c) + (a^5*b^2 + 2*a^3*b^4 + a*b^6)*d)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)**2)/(a+b*tan(d*x+c))**2,x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [A]  time = 1.63448, size = 329, normalized size = 2.1 \begin{align*} -\frac{\frac{2 \,{\left (B a^{2} + 2 \, C a b - B b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{{\left (C a^{2} - 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{2 \,{\left (C a^{4} + 3 \, C a^{2} b^{2} - 2 \, B a b^{3}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b^{2} + 2 \, a^{2} b^{4} + b^{6}} + \frac{2 \,{\left (C a^{4} \tan \left (d x + c\right ) + 3 \, C a^{2} b^{2} \tan \left (d x + c\right ) - 2 \, B a b^{3} \tan \left (d x + c\right ) + B a^{4} + 2 \, C a^{3} b - B a^{2} b^{2}\right )}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )}{\left (b \tan \left (d x + c\right ) + a\right )}}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/2*(2*(B*a^2 + 2*C*a*b - B*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) + (C*a^2 - 2*B*a*b - C*b^2)*log(tan(d*x +
c)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) - 2*(C*a^4 + 3*C*a^2*b^2 - 2*B*a*b^3)*log(abs(b*tan(d*x + c) + a))/(a^4*b^2
+ 2*a^2*b^4 + b^6) + 2*(C*a^4*tan(d*x + c) + 3*C*a^2*b^2*tan(d*x + c) - 2*B*a*b^3*tan(d*x + c) + B*a^4 + 2*C*a
^3*b - B*a^2*b^2)/((a^4*b + 2*a^2*b^3 + b^5)*(b*tan(d*x + c) + a)))/d